package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sc.nft.dto.TaskPlanPrizeDTO;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.enums.task.DrawPriceTypeEnum;
import com.sc.nft.enums.task.TaskPrizeTypeEnum;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.TaskDrawPrize;
import com.sc.nft.mapper.TaskDrawPrizeMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 任务奖励领取表(sc_task_draw_prize)数据DAO
 *
 * @author 张翔宇
 * @since 2023-03-31 17:13:26
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class TaskDrawPrizeDao extends ServiceImpl<TaskDrawPrizeMapper, TaskDrawPrize> {

    public List<TaskDrawPrize> getTaskPrize(Long userId){
        LambdaQueryWrapper<TaskDrawPrize> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TaskDrawPrize::getUserId,userId);
        wrapper.eq(TaskDrawPrize::getStatus,Boolean.FALSE);
        wrapper.orderByDesc(TaskDrawPrize::getId);
        return list(wrapper);
    }


    public int getCount(Long taskId, Long taskPlanId, DrawPriceTypeEnum drawType){
        LambdaQueryWrapper<TaskDrawPrize> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TaskDrawPrize::getTaskId,taskId);
        wrapper.eq(TaskDrawPrize::getTaskPlanId,taskPlanId);
        wrapper.eq(TaskDrawPrize::getDrawType,drawType);
        return count(wrapper);
    }
    public List<TaskPlanPrizeDTO> getTaskPrizeByTaskPlanIdList(List<Long> taskPlanIdList){
        return baseMapper.getTaskPrizeByTaskPlanIdList(taskPlanIdList);
    }

    public Integer getCountByEquityId(Long equityId){
        return baseMapper.getCountByEquityId(equityId);
    }
}